/*
 * Title: WADS
 * Description: Web-based Auto flow Documents System
 * Copyright: 2007
 * Company: CoE
 * @author: Mr.Nattasan Wang-Aphisit
 * @version 1.1
 */

package wads.app;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Vector;

public class ReadOrganization {

  private File fileOrg;
  //String field;
  private Enumeration enumerator;
  private Vector<String> allData;
  private Vector<String> data;

  public ReadOrganization(String file) {
    this.fileOrg = new File(file);
    String temp = null;
    allData = new Vector<String>();
    data = new Vector<String>();

    //read Org to vector
    try{
      FileInputStream fin = new FileInputStream(fileOrg);
      //DataInputStream din = new DataInputStream(fin);
      BufferedReader br = new BufferedReader(new InputStreamReader(fin));
      while((temp = br.readLine()) != null){
        allData.add(temp);
      }
      br.close();
    }catch(Exception e){}
  }

  public Vector getData(int index){

    String temp = null;
    String dataTemp = null;
    StringTokenizer token;
    enumerator = allData.elements();
    while(enumerator.hasMoreElements()){
       temp = (String)enumerator.nextElement();
       token = new StringTokenizer(temp,":");
       for(int i=0; i<index; i++){
          dataTemp = token.nextToken();
       }
       System.out.println(dataTemp);
       data.add(dataTemp);
    }
    //manage Vector
    return data;
  }
}